import 'dart:async';

Future<int> test1() async {
  int x = 111;
  if (x == 111) {
    throw IntegerDivisionByZeroException();
  }
  return Future.value(x);
}

Future<String> one() => new Future.value("from one");

Future<String> two() => new Future.value("error from two");

Future<String> three() => new Future.value("from three");

Future<String> four() => new Future.value("from four");

Future<void> main() async {
  onError(e) {
    print('@异常：$e');
  }

  onError2(e) {
    print('异常：$e');
  }

  test1().then((value) {
    print(value);
    throw Exception('e1');
  }).whenComplete(() {
    throw Exception('e12');
    print('完成');
  }).catchError(onError2, test: (e) => e is Exception);

  new Future(() => print('future #2 of 4')).then((_) => print('future #2a')).then((_) {
    print('future #2b');
    scheduleMicrotask(() => print('microtask #0 (from future #2b)'));
  }).then((_) => print('future #2c'));
}
